<?php
/**
 * User: dimka3210
 * Date: 21.11.13
 * Time: 11:14
 */
include_once('../core/autoload.php');
?>
<html>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/static/css/my.css">
</head>
<body>
<?php
$user = new User();
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if (!$user->checkAdminRight() || !$id) {
    header('Location: /');
}

$storage = Storage::getInstance();

if ($id) {
    $row = $storage->findRowById($id);

    if (!$row) {
        die('<h1>There is no such record</h1>');
    }
}

if (!$storage->deleteRow($id)) {
    die('Not removed');
} else {
    header('Location: /admin');
}
?>
</body>
</html>